package com.zhaozhaonews.wemedia.controller;


import com.zhaozhaonews.model.common.dto.PageResponseResult;
import com.zhaozhaonews.model.common.dto.ResponseResult;
import com.zhaozhaonews.model.wemedia.dto.WmMaterialDto;
import com.zhaozhaonews.model.wemedia.entity.WmMaterial;
import com.zhaozhaonews.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 * 自媒体图文素材信息表 前端控制器
 * </p>
 *
 * @author WanJL
 * @since 2025-02-17
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Resource
    private WmMaterialService wmMaterialService;
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {

        return wmMaterialService.uploadPicture(multipartFile);
    }

    @PostMapping("/list")
    public PageResponseResult list(@RequestBody WmMaterialDto wmMaterialDto) {
        PageResponseResult pageResponseResult = wmMaterialService.list(wmMaterialDto);
        log.info("分页结果----》{}", pageResponseResult);
        log.info("当前页数-->{}", pageResponseResult.getCurrentPage());
        log.info("总页数-->{}", pageResponseResult.getSize());
        log.info("总条数-->{}", pageResponseResult.getTotal());

        return pageResponseResult;
    }
}

